<?php

/**
 * 款项小类条目仓库
 * @author wangwx 2015-5-12
 */
namespace common\repositories\myhtsq;
use common\repositories\BaseRepository;
use common\support\StringHelper;
use common\entities\myhtsq\MoneyCategoryItemEntity;
class MoneyCategoryItemRepository extends BaseRepository{
	
	/**
	 * 构造方法
	 * @param unknown $config (optional)
	 */
	public function __construct($config = [])
	{
		parent::__construct($config);
	}
	
	
	/**
	 * 获取所有款项小类
	 * @return array
	 */
	public static function getAllMoneyCategoryItem() {
		return MoneyCategoryItemEntity::find()->all();
	}
	
	/**
	 * 根据性质id,获取款项小类列表
	 * @param string $propertyId 性质id
	 * @return array
	 */
	public static function getAllMoneyCategoryItemListByPropertyId($propertyId) {
		return MoneyCategoryItemEntity::find()->all();
		//坏味道修复 暂时注释 是原逻辑
		//return MoneyCategoryItemEntity::find()->where('find_in_set(:propertyId,property_id)')->params([':propertyId'=>$propertyId])->all();
	}
	
	/**
	 * 根据款项id,获取款项名称
	 * @param string $moneyCategoryItemId 款项小类id
	 * @return string 款项名称
	 */
	public static function getMoneyCategoryItemNameByItemId($moneyCategoryItemId){
		 $str = MoneyCategoryItemEntity::find()->select('money_category_item_name')->where(['money_category_item_id'=>$moneyCategoryItemId])->scalar();
		 if (empty($str)) {
		 	$str = '';
		 }
		 return $str;
	}

	/**
	 * 根据id,获取名称
	 * @param string $moneyCategoryItemName 名称
	 * @return string 名称
	 */
	public static function getMoneyCategoryItemIdByItemName($moneyCategoryItemName)
	{
		$str = MoneyCategoryItemEntity::find()->select('money_category_item_id')->where(['money_category_item_name' => $moneyCategoryItemName])->scalar();
		if (empty($str)) {
			$str = '';
		}
		return $str;
	}
	
}
